package com.songlanyun.modules.order.controller.api;

import java.util.List;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.songlanyun.modules.account.controller.common.AbstractApiController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.songlanyun.modules.order.entity.ReservationRecordEntity;
import com.songlanyun.modules.order.service.ReservationRecordService;
import com.songlanyun.common.utils.R;


/**
 * 服务商品预约记录
 *
 * @author wuchao
 * @email sunlightcs@gmail.com
 * @date 2021-03-19 13:54:17
 */
@RestController
@RequestMapping("api/service/goods/reservation/record")
public class ReservationRecordApiController extends AbstractApiController {
    @Autowired
    private ReservationRecordService reservationRecordService;

    /**
     * 会员查看自己的预约记录
     */
    @GetMapping("/my-list")
    //@RequiresPermissions("reservationrecord:reservationrecord:list")
    public R myList() {
        List<ReservationRecordEntity> list = reservationRecordService.myList(getUserId(true));

        return R.ok().put("list", list);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("reservationrecord:reservationrecord:info")
    public R info(@PathVariable("id") Long id) {
        ReservationRecordEntity reservationRecord = reservationRecordService.getById(id);

        return R.ok().put("data", reservationRecord);
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete/{id}")
    //@RequiresPermissions("reservationrecord:reservationrecord:delete")
    public R delete(@PathVariable("id") Long id) {
        reservationRecordService.removeById(id);

        return R.ok();
    }

}
